package com.eshipenet.shipnet
import org.joda.time.DateTime
import play.api.libs.json._

package object equipmentextbuilder {
  implicit val jodaDateTimeReads: Reads[DateTime] = Reads[DateTime] {
    case JsString(str) => JsSuccess(DateTime.parse(str))
    case JsNumber(num) => JsSuccess(new DateTime(num.toLong))
    case other         => JsError(s"invalid DateTime format: $other")
  }

  implicit val jodaDateTimeWrites: Writes[DateTime] = (o: DateTime) => JsString(o.toString())
}
